Lib,
Rlib,
Dylib,
+ RustcMacro,
Other(String),
}
"lib" => LibKind::Lib,
"rlib" => LibKind::Rlib,
"dylib" => LibKind::Dylib,
+ "rustc-macro" => LibKind::RustcMacro,
s => LibKind::Other(s.to_string()),
}
}
LibKind::Lib => "lib",
LibKind::Rlib => "rlib",
LibKind::Dylib => "dylib",
+ LibKind::RustcMacro => "rustc-macro",
LibKind::Other(ref s) => s,
}
}
match *self {
LibKind::Lib |
LibKind::Rlib |
- LibKind::Dylib => true,
+ LibKind::Dylib |
+ LibKind::RustcMacro => true,
LibKind::Other(..) => false,
}
}
let lib = match self.lib {
Some(ref lib) => {
try!(lib.validate_library_name());
+ try!(lib.validate_crate_type());
Some(
TomlTarget {
name: lib.name.clone().or(Some(project.name.clone())),
bench: Option<bool>,
doc: Option<bool>,
plugin: Option<bool>,
+ rustc_macro: Option<bool>,
harness: Option<bool>,
}
bench: None,
doc: None,
plugin: None,
+ rustc_macro: None,
harness: None,
}
}
None => Err(human("bench target bench.name is required".to_string()))
}
}
+
+ fn validate_crate_type(&self) -> CargoResult<()> {
+ if self.plugin == Some(true) && self.rustc_macro == Some(true) {
+ Err(human("lib.plugin and lib.rustc-macro cannot both be true".to_string()))
+ } else {
+ Ok(())
+ }
+ }
}
impl PathValue {
.set_doctest(toml.doctest.unwrap_or(t2.doctested()))
.set_benched(toml.bench.unwrap_or(t2.benched()))
.set_harness(toml.harness.unwrap_or(t2.harness()))
- .set_for_host(toml.plugin.unwrap_or(t2.for_host()));
+ .set_for_host(match (toml.plugin, toml.rustc_macro) {
+ (None, None) => t2.for_host(),
+ (Some(true), _) | (_, Some(true)) => true,
+ _ => false,
+ });
}
fn lib_target(dst: &mut Vec<Target>,
Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(),
None => {
vec![ if l.plugin == Some(true) {LibKind::Dylib}
+ else if l.rustc_macro == Some(true) {LibKind::RustcMacro}
else {LibKind::Lib} ]
}
};
# for Cargo to correctly compile it and make it available for all dependencies.
plugin = false
+# If the target is meant to be a "macros 1.1" procedural macro, this field must
+# be set to true.
+rustc-macro = false
+
# If set to false, `cargo test` will omit the `--test` flag to rustc, which
# stops it from generating a test harness. This is useful when the binary being
# built manages the test runner itself.
crate-type = ["dylib"] # could be `staticlib` as well
```
-The available options are `dylib`, `rlib`, `staticlib`, and `cdylib`. You
-should only use this option in a project. Cargo will always compile packages
-(dependencies) based on the requirements of the project that includes them.
+The available options are `dylib`, `rlib`, `staticlib`, `cdylib`, and
+`rustc-macro`. You should only use this option in a project. Cargo will always
+compile packages (dependencies) based on the requirements of the project that
+includes them.
You can read more about the different crate types in the
[Rust Reference Manual](https://doc.rust-lang.org/reference.html#linkage)